#include <iostream>

using namespace std;

void func1(int a)
{
    a = 5;
}

void func2(int* a)
{
    *a = 17;
}

void func3(int& a)
{
    a = 27;
}


int main()
{
    // 栈内存空间分配内存，自动释放
    int a = 7;
    func1(a);
    cout << "a = " << a << endl;
    func2(&a);
    cout << "a = " << a << endl;
    func3(a);
    cout << "a = " << a << endl;

    // 堆内存空间分配内存
    int *b = new int(9);
    cout << "b = " << b << ", *b = " << *b << endl;

    delete b;
    b = nullptr;
    
    return 0;
}